package com.virus.coronavirus.controller;

import com.virus.coronavirus.model.vo.CompareVO;
import com.virus.coronavirus.model.vo.MeetVO;
import com.virus.coronavirus.response.ResponseBean;
import com.virus.coronavirus.service.TrackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: Bbeginner
 * @Date: 2021/3/21 14:29
 * @Version 1.0
 **/
@RestController
@RequestMapping("/virus/meet")
@Validated
@Api(tags = "疫情防控模块-算法相关接口")
public class ActionController {
    @Autowired
    private TrackService trackService;

    @ApiOperation(value = "查找用户附近的风险区域", notes = "指定距离,获取附近的风险区域")
    @RequiresPermissions({"track:find"})
    @GetMapping("/areadistance")
    public ResponseBean areadistance(Long id1, Double dis) throws Exception {
        List<CompareVO> areadistance = trackService.areadistance(id1, dis);
        return ResponseBean.success(areadistance);
    }

    @ApiOperation(value = "查找相交轨迹", notes = "指定时间,获取相交的轨迹")
    @RequiresPermissions({"track:find"})
    @GetMapping("/useraction")
    public ResponseBean useraction(Long id1, Long id2, Double dis, long time) throws Exception {
        List<MeetVO> useraction = trackService.useraction(id1, id2, dis, time);
        return ResponseBean.success(useraction);
    }

    @ApiOperation(value = "判定是否相遇", notes = "指定时间,进行判定")
    @RequiresPermissions({"track:find"})
    @GetMapping("/userconflict")
    public ResponseBean userconflict(Long id1, Long id2, Double dis, long time) throws Exception {
        Boolean useraction = trackService.userconflict(id1, id2, dis, time);
        return ResponseBean.success(useraction);
    }
}
